<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<meta http-equiv="X-UA-Compatible" content="ie=edge">
		<title></title>
		<link rel="stylesheet" type="text/css" href="js/elementUI/index.css"/>
		<link rel="stylesheet" href="css/main.css">
		
	</head>
	<body>
		<div class="main" id="app">
			<div class="contbox">
				<div class="title">{{name}}</div>
				<div class="inputbox">
					<div class="filebox">
						<span class="ts">license.lic</span>
					</div>
					<el-button class="localbtn" @click="install" :disabled="isclick">开始安装</el-button>
				</div>
				<div class="jdt">
					<el-progress :text-inside="true" :stroke-width="24" :percentage="installnum" status="success"></el-progress>
				</div>
				
			</div>
			
		</div>
		<script src="js/jquery-3.3.1.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/vue.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/elementUI/index.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/axios.min.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			let vm = new Vue({
				el: '#app',
				data() {
					return{
						ip:"",
						installnum:0,
						interval:null,
						name:"",
						isclick:false
					}
				},
				computed: {},
				created() {
					this.ip=window.location.origin;
				},
				mounted(){
					let _this=this;
					$('document').ready(function () {
						axios.get(_this.ip+"/license/getInfo").then(res=>{
							_this.name=res.data.title;
						});
					});	
				}, 
				methods: {	
				  install(){
					  console.log(this.ip);
					  this.isclick=true;
					  //开始安装
					  axios.post(this.ip+"/license/reset").then(res=>{
						  console.log(res);
						if(res.data.code==1){
							
							this.interval=setInterval(()=>{
								if(this.installnum<100){
									this.installnum+=1;
								}else{
									clearInterval(this.interval);
									this.$alert('安装成功，跳转至登录页', '', {
									  confirmButtonText: '确定',
									  showClose:false,
									  callback: action => {
										window.location.href="license-login.html"
									  }
									});
								}
							},30);
							
						}else{
							this.$message.error(res.data.msg);
							this.isclick=false;
						}
					  })
				  }
				}
			})
		</script>
	</body>
</html>
